package comparable_test;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2024-10-11
 * Time: 17:58
 */
public class Test {
    public static void bubbleSort(Student[] s1){
        for (int i = 0; i<s1.length-1; i++){
            for (int j = 0;j<s1.length-1-i;j++){
                if(s1[j].compareTo(s1[j+1])>0){
                    Student tmp = s1[j];
                    s1[j] = s1[j+1];
                    s1[j+1] = tmp;
                }
            }
        }
    }
    public static void sortl(Comparable[] array) {
        for (int bound = 0; bound < array.length; bound++) {
            for (int cur = array.length - 1; cur > bound; cur--) {
                if (array[cur - 1].compareTo(array[cur]) > 0) {
// 说明顺序不符合要求, 交换两个变量的位置
                    Comparable tmp = array[cur - 1];
                    array[cur - 1] = array[cur];
                    array[cur] = tmp;
                }
            }
        }
    }

    public static void main(String[] args) {
        Student s1 = new Student("a",96);
        Student s2 = new Student("b",99);
        ComName cm = new ComName();
        int ret = cm.compare(s1,s2);
        if(ret>0){
            System.out.println("s1 > s2");
        }else {
            System.out.println("s1 < s2");
        }
    }
    public static void main3(String[] args) {


        Student[] students = new Student[] {
                new Student("张三", 95),
                new Student("李四", 96),
                new Student("王五", 97),
                new Student("赵六", 92),
        };
        System.out.println(Arrays.toString(students));
        bubbleSort(students);
        //Arrays.sort(students);
        //sortl(students1);
        System.out.println(Arrays.toString(students));




    }


    public static void main1(String[] args) {
        Student s1 = new Student("zs",96);
        Student s2 = new Student("ls",99);
        if(s1.compareTo(s2)>0){
            System.out.println("da");
        }else{
            System.out.println("xioa");
        }
    }
    /*if(s1>s2){
        不知道比较规则
    }*/

}
